package com.dayatang.android.Adapter;

import java.util.HashMap;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dayatang.android.Activity.R;

public class PMOvertTimeStepAdapter extends BaseAdapter {
	
	private List<HashMap<String, Object>> listItem;
	private LayoutInflater listContainer;           

	class ListItemView{
		private TextView subProjectNameTextView;
		private TextView workStepNameTextView;
		private TextView workStepResponsibleTextView;
		private TextView overTimeDayTextView;
	}
	
	public PMOvertTimeStepAdapter(Context context, List<HashMap<String, Object>> listItem) {
		this.listItem = listItem;
		listContainer = LayoutInflater.from(context);  
	}

	public int getCount() {
		return listItem.size();
	}

	public Object getItem(int position) {
		return listItem.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		
		ListItemView  listItemView = null;
		
		if (convertView == null) {
			listItemView = new ListItemView();
			convertView = listContainer.inflate(R.layout.pm_overtime_listview_item, null);
			
			listItemView.subProjectNameTextView = (TextView) convertView.findViewById(R.id.pm_subproject_name);
			listItemView.workStepNameTextView = (TextView) convertView.findViewById(R.id.pm_workstep_name);
			listItemView.workStepResponsibleTextView = (TextView) convertView.findViewById(R.id.pm_workstep_responsible);
			listItemView.overTimeDayTextView = (TextView) convertView.findViewById(R.id.pm_overtime_day);
			
            convertView.setTag(listItemView);    
		} else {    
            listItemView = (ListItemView)convertView.getTag();    
        }  
		
		listItemView.subProjectNameTextView.setText((String)listItem.get(position).get("ItemSubProjectName"));
		listItemView.workStepNameTextView.setText((String)listItem.get(position).get("ItemSubProjectWorkStep"));
		listItemView.workStepResponsibleTextView.setText((String)listItem.get(position).get("ItemSubProjectWorkStepResponsible"));
		listItemView.overTimeDayTextView.setText((String)listItem.get(position).get("ItemSubProjectOverTimeDay"));
		
		return convertView;
	}

}
